var phoneReg = /^1[0-9]{10}$/;
var wait = 60;
//控制获取验证码60秒停用
function time(o) {
	if (wait == 0) {
		o.textContent = "获取验证码";
		wait = 60;
		o.disabled = 'false';
	} else {
		o.textContent = "重新发送(" + wait + ")";
		wait--;
		setTimeout(function() {
			time(o)
		}, 1000)
	}
}
function getCode() {
	var maincode  = document.getElementById("maincode");
	var phone = document.getElementById('phone');
    var code = document.getElementById('code');
	if (phone.value) {
		if (!phoneReg.exec(phone.value)) {
			mui.toast('手机号码错误，请修改后再获取');
		} else {
			var jsons = "account=" + phone.value + "&smsType=2";
			var codeUrl = getUrl('checkCode');
			maincode.disabled = true;
			mui.ajax(codeUrl, {
				data: jsons,
				dataType: 'json',
				type: 'post',
				timeout: 3000,
				success: function(data) {
					mui.toast('验证码正在发送中，请注意查收');
					time(maincode);
				},
				error: function(xhr, type, errorThrown) {
					//异常处理；
					mui.toast('验证码发送失败，请重新发送');
				}
			});
		}
	} else {
		mui.toast('请输入手机号')
	}
}
function next() {
	var phone = document.getElementById('phone').value;
	var vcode = document.getElementById('code').value;
	var dataString = "account=" + phone + "&vcode=" + vcode;
	if (!phone) {
		mui.toast('请输入手机号');
		return;
	}
	if (!code) {
		mui.toast('请输入验证码');
		return;
	}
	var codeUrl = getUrl("searchPwd");
	plus.nativeUI.showWaiting();
	mui.ajax(codeUrl, {
		data: dataString,
		dataType: 'json',
		type: 'post',
		timeout: 3000,
		success: function(data) {
			plus.nativeUI.closeWaiting();
			if(data){
				if(data.code=='0'){
					localStorage.pwdPhone = phone;
					document.getElementById('phone').value = '';
					document.getElementById('code').value = '';
					OpenNewWin({
						id :'findPwdHead.html',
						url:'findPwdHead.html'
					})
				}else{
					mui.toast(data.msg);
				}
			}else{
				mui.toast('网络连接异常，请重新提交');
			}
		},
		error: function(xhr, type, errorThrown) {
			plus.nativeUI.closeWaiting();
			//异常处理；
			mui.toast('网络连接异常，请重新提交');
		}
	});
}